package com.bing.util;

import com.bing.util.exception.BlankTextException;
import com.bing.util.exception.EmptyTextException;

public class AssertUtils {
	
	private AssertUtils() {}

	private static final String EMPTY = "";
	
	public static void notNull(Object obj) {
		notNull(obj, "obj must not be null!");
	}
	
	public static void notNull(Object obj, String msg) {
		
		if(null == obj) {
			throw new NullPointerException(msg);
		}
	}
	
	public static void notEmpty(String text) {
		notEmpty(text, "text must not be empty!");
	}
	
	public static void notEmpty(String text, String msg) {
		
		if(null == text || EMPTY.equals(text)) {
			throw new EmptyTextException(msg);
		}
	}
	
	public static void notBlank(String text) {
		notBlank(text, "text must not be blank!");
	}
	
	public static void notBlank(String text, String msg) {
		
		if(null == text || EMPTY.equals(text.trim())) {
			throw new BlankTextException(msg);
		}
	}
	
	
}
